@extends('admin.layout.layout')
@section('content') 

@component('admin.components.content.rightContent')
    @slot('rightContent')

        <div class="mt-3  mb-3  d-flex justify-content-between container-fluid">

            <div class="col-md-3 row justify-content-between">
                    <form action="?" class="d-flex">
                        <input type="hidden" value="{{$is_trashed}}" name="trashed">
                        <input type="text" class="form-control form-control-sm col-md-9" name="keyWord" placeholder="按角色名搜索" value="{{$keyWord}}">
                        <button type="submit" class="btn btn-secondary"><i class="icon-search"></i></button>
                    </form>
                </div>
            
            <div class="col-md-9 row justify-content-end">

                @if($is_trashed)
                
                    @component('admin.components.button.button',[
                        'text'=>'恢复已选',
                        'style'=>'info',
                        'classes'=>'restore-checked mr-1',
                        'action'=>url('/admin/role/restoreChecked')
                    ])
                    @endcomponent

                    @component('admin.components.button.href',[
                        'href'=>url('/admin/role'),
                        'text'=>'返回列表',
                        'style'=>'success'
                    ])
                    @endcomponent
                    
                @else  
                    @component('admin.components.button.button',[
                        'text'=>'新增角色',
                        'mini'=>url('/admin/role/create'),
                        'title'=>'新增角色',
                        'classes'=>'mr-1'
                    ])
                    @endcomponent

                    @component('admin.components.button.button',[
                        'text'=>'删除已选',
                        'style'=>'danger',
                        'classes'=>'delete-checked mr-1',
                        'action'=>url('/admin/role/deleteChecked')
                    ])
                    @endcomponent

                    @component('admin.components.button.href',[
                        'href'=>url('/admin/role?trashed=1'),
                        'text'=>'查看回收站',
                        'style'=>'secondary'
                    ])
                    @endcomponent
                @endif

            </div>
        </div>
        <table class="table table-striped table-hover r-0">
            <thead>
            <tr class="no-b">
                <th style="width: 30px">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" id="checkedAll" class="custom-control-input"><label class="custom-control-label" for="checkedAll"></label>
                    </div>
                </th>
                <th>角色名称 </th>
                <th>可访问菜单</th>
                <th>排序</th>
                <th>创建时间</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
                @forelse($pageListData as $item)
                    <tr>
                        <td>
                            <div class="custom-control custom-checkbox">
                                <input type="checkbox" id="checkbox{{$item->id}}" class="custom-control-input table-checkbox"><label class="custom-control-label" for="checkbox{{$item->id}}"></label>
                            </div>
                        </td>
                        <td>{{$item->role_name}}</td>
                        <td>
                            @if ($item->menus)
                                <div class="ov" style="width:200px;">
                                    @forelse ($item->menus as $itemm)
                                        {{$itemm->menu_name}}
                                    @empty
                                        无可访问菜单
                                    @endforelse
                                </div>
                            @endif
                        </td>
                        <td>{{$item->sort}}</td>
                        <td>{{$item->created_at}}</td>
                        <td>{{$item->updated_at}}</td>
                        <td>
                            <div class="d-flex">
                            @if($is_trashed)

                                @component('admin.components.form.formButton',[
                                    'action'=>url('/admin/role/restoreChecked'),
                                    'right'=>'恢复',
                                    'title'=>'是否恢复?',
                                    'icon'=>'restore',
                                    'style'=>'info'
                                ])
                                    @slot('slot')
                                         <input type="hidden" name="id" value="{{$item->id}}">
                                    @endslot
                                @endcomponent

                                @component('admin.components.form.formButton',[
                                    'action'=>url('/admin/role/forceDeleteChecked'),
                                    'right'=>'强制删除',
                                    'title'=>'是否强制删除?',
                                    'icon'=>'delete',
                                    'style'=>'danger',
                                    'dangerMode'=>true
                                ])
                                    @slot('slot')
                                        <input type="hidden" name="id" value="{{$item->id}}">
                                    @endslot
                                @endcomponent

                            @else

                                @component('admin.components.button.hrefButton',[
                                    'mini'=>url('/admin/role',['id'=>$item->id,'method'=>'edit']),
                                    'text'=>'编辑',
                                    'title'=>'角色编辑',
                                    'titleText'=>'编辑',
                                    'icon'=>'pencil'
                                ])
                                @endcomponent

                                @component('admin.components.form.formButton',[
                                    'action'=>url('/admin/role',$item->id),
                                    'right'=>'删除',
                                    'title'=>'是否删除?',
                                    'icon'=>'delete',
                                    'style'=>'danger',
                                    'dangerMode'=>true,
                                    'method'=>'delete'
                                ])
                                @endcomponent

                            @endif
                            </div>
                        </td>
                    </tr>
                @empty 
                    <tr>
                        <td colspan="8" align="center">没有更多了</td>
                    </tr>
                @endforelse
            </tbody>
        </table>
        {{$pageListData->appends(['trashed'=>$is_trashed,'keyWord'=>$keyWord])->links()}}

    @endslot

@endcomponent
  
@endsection